package com.anolesoft.qxgl.controller.employee;

import com.anolesoft.common.core.constant.HttpStatus;
import com.anolesoft.common.core.web.domain.AjaxResult;
import com.anolesoft.qxgl.dto.employee.EmployeeDto;
import com.anolesoft.qxgl.service.employee.inf.EmployeeServiceInf;
import com.anolesoft.yr.util.Constants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;


@RestController
@CrossOrigin
@RequestMapping("/qjwl/employeeUpdate")
public class EmployeeUpdateController {
    @Autowired
    private EmployeeServiceInf employeeServiceInf;

    /**
     * 修改密码
     *
     * @param employeeDto
     * @return
     */
    @PostMapping(value = "/password", produces = MediaType.APPLICATION_JSON_VALUE)
    @ResponseBody
    public AjaxResult updatePassword(@RequestBody EmployeeDto employeeDto) {
        int updatePassword = employeeServiceInf.updatePassword(employeeDto);
        return new AjaxResult(HttpStatus.SUCCESS, Constants.QUERY_SUCCESS_MESSAGE, "修改密码成功!");
    }

    /**
     * 重置密码
     *
     * @param employeeDto
     * @return
     */
    @PostMapping(value = "/resetPassword", produces = MediaType.APPLICATION_JSON_VALUE)
    @ResponseBody
    public AjaxResult resetPassword(@RequestBody EmployeeDto employeeDto) {
        int resetPassword = employeeServiceInf.resetPassword(employeeDto);
        return new AjaxResult(HttpStatus.SUCCESS, Constants.QUERY_SUCCESS_MESSAGE, "重置密码成功!");
    }
}
